<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>TradeList</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />

<link href="resources/css/home.css" rel="stylesheet" type="text/css" />
<link href="http://tjs.sjs.sinajs.cn/t3/style/css/common/card.css"
	type="text/css" rel="stylesheet" />
<script type="text/javascript" src="resources/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="resources/js/sina/wb.js"></script>
<script type="text/javascript" src="resources/js/common.js"></script>
<script>
	function follow(tradeId) {
		$.ajax({
			type : "post",
			dataType : "text",
			url : "sinaaction/followAction.do?tradeId=" + tradeId,
			success : function(msg) {
				var regExp = /\d+/;
				if (!regExp.test(msg)) {
					alert(msg);
				} else {
					alert("关注成功，您将获得" + msg + "个粉币。");
					$("#nowBalance").html(
							parseInt($("#nowBalance").html()) + parseInt(msg));
					$("#followNum").html(parseInt($("#followNum").html()) + 1);
					$("#remainingNum").html(
							parseInt($("#remainingNum").html()) - 1);
				}
				$("#trade" + tradeId).find(".followButton").attr("disabled",
						"disabled");
			},
			error : function() {
				alert("连接失败。");
			}
		});
	}
</script>
</head>
<body style="background: #fff">
	<div style="margin: 10px 5px 5px 5px">
		<div id="sort_bar">
			<div id="platform_cats_box">
				<label for="categories">兴趣：</label> <select name="categories"
					id="categories" style="width: 150px">
					<option value="">音乐</option>
					<option value="">体育</option>
					<option value=""></option>
					<option value=""></option>
				</select>
			</div>
			<div id="sort_by_box">
				<label for="sort_by">位置：</label> <select name="sort_by" id="sort_by"
					style="width: 150px">
					<option value="">北京</option>
					<option value="">上海</option>
					<option value="">天津</option>
				</select>
			</div>
		</div>
		<div class="twiendingHalf">
			<div id="apps_listing_grid">
				<s:iterator id="tradeInfo" value="tradeList" status="tl">
					<s:if test="#tl.index % 6 == 0">
						<div class="appy_row grouping_0">
					</s:if>
					<s:if test="#tl.index % 3 == 0 && #tl.index % 6 != 0">
						<div class="appy_row grouping_3">
					</s:if>
					<div class="app_listing_container" id="trade${tradeInfo.tradeId }">
						<img src="${tradeInfo.tuUserinfo.sinaInfoBean.profileImageUrl }"
							class="app_listing_thumb"
							alt="${tradeInfo.tuUserinfo.sinaInfoBean.screenName }"
							wb_user_id="${tradeInfo.tuUserinfo.sinaInfoBean.sinaId }"
							wb_screen_name="${tradeInfo.tuUserinfo.sinaInfoBean.screenName }" />
						<div class="app_listing_deets" style="margin-top: -10px">
							<h3>${tradeInfo.tuUserinfo.sinaInfoBean.screenName }</h3>
							<small><em>${tradeInfo.tuUserinfo.sinaInfoBean.sex }</em>
							</small><small><em>获得<b>${tradeInfo.unitPrice }</b>粉币</em> </small>
							<button onclick="follow('${tradeInfo.tradeId }')"
								class="followButton">关注</button>
						</div>
					</div>
					<s:if test="(#tl.index + 1) % 3 == 0 || #tl.last">
			</div>
			</s:if>
			</s:iterator>
		</div>
	</div>
</body>